Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@preact/signals-core

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@preact/signals-core

Manage state with style in every framework

  • 1.8.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
295K
increased by18.14%
Maintainers
0
Weekly downloads
 
Created

What is @preact/signals-core?

@preact/signals-core is a state management library designed for Preact applications. It provides reactive signals that can be used to manage and update state efficiently. The package is lightweight and focuses on providing a simple API for state management.

What are @preact/signals-core's main functionalities?

Creating Signals

Signals are reactive state containers. You can create a signal with an initial value and update it. The value of the signal can be accessed and modified using the `.value` property.

const { signal } = require('@preact/signals-core');
const count = signal(0);
console.log(count.value); // 0
count.value = 1;
console.log(count.value); // 1

Computed Values

Computed values are derived from other signals. They automatically update when the signals they depend on change.

const { signal, computed } = require('@preact/signals-core');
const count = signal(0);
const doubleCount = computed(() => count.value * 2);
console.log(doubleCount.value); // 0
count.value = 2;
console.log(doubleCount.value); // 4

Effects

Effects are functions that run whenever the signals they depend on change. They are useful for performing side effects in response to state changes.

const { signal, effect } = require('@preact/signals-core');
const count = signal(0);
effect(() => {
  console.log(`Count is now ${count.value}`);
});
count.value = 1; // Logs: Count is now 1

Other packages similar to @preact/signals-core

FAQs

Package last updated on 04 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc